//workflow js 
//create by honeyao

function addFormatDocsToModule(type, fatherModule, paramsId1, paramsId2,
		paramsId3, paramsId4, selectId, selectName) {
	if (fatherModule != null && fatherModule == "WAI") {
		ajaxAnywhere
				.getAJAX('workflow.do?method=preCreateApplicationItemByDocumentTemplate&documentTemplateId=' + selectId);
	} else {
		$('documentTemplateId').value = selectId;
		$('documentTemplateName').value = selectName;
	}
}
function getMineOriginateWorkflow(checked) {
	if (checked) {
		var url = "workflow.do?method=mineOriginateWorkflowlist";
		ajaxAnywhere.getAJAX(url);
		document
				.getElementsByName("voa.value(Workflow).field(displayMineOriginate)")[0].value = "true";
	} else {
		var url = "workflow.do?method=listWorkflow";
		ajaxAnywhere.getAJAX(url);
		document
				.getElementsByName("voa.value(Workflow).field(displayMineOriginate)")[0].value = "false";
	}
}
function _saveWorkflowTemplateInfo() {
	$(editTemplateInfoForm).action = $(editTemplateInfoForm).action
			+ "&optionType=listWFT";
	$(editTemplateInfoForm).submit();
}

function _saveWFTAndLoginStep() {
	$(editTemplateInfoForm).action = $(editTemplateInfoForm).action
			+ "&optionType=listWFS";
	$(editTemplateInfoForm).submit();
}

function _gotoWorkflowTemplateEdit(_id, isInPrj) {
	var url = "workflow.do?method=preEditWorkflowTemplate&templateId=" + _id
			+ "&optionType=listWFS";
	if (isInPrj != null && isInPrj == "true") {
		url = "workflow.do?method=preEditWorkflowTemplate&templateId=" + _id
				+ "&optionType=listWFS&view=true";
	}
	$(listTemplateStepForm).action = url;
	$(listTemplateStepForm).submit();
}

function _gotoWorkflowTemplateList(_id) {
	$(listWorkflowTransition).action = "workflow.do?method=listWorkflowTemplate&templateId="
			+ _id;
	$(listWorkflowTransition).submit();
}

function _gotoWorkflowTransitionList(_id) {
	$(listTemplateStepForm).action = "workflow.do?method=listWorkflowTransition&templateId="
			+ _id;
	$(listTemplateStepForm).submit();
}

function _gotoWorkflowStepList(_id) {
	$(listWorkflowTransition).action = "workflow.do?method=listWorkflowStep&templateId="
			+ _id;
	$(listWorkflowTransition).submit();
}

function _saveWorkflowTransition(_id) {
	$(listWorkflowTransition).action = "workflow.do?method=createWorkflowTransition&templateId="
			+ _id;
	$(listWorkflowTransition).submit();
}

// --------------------------------------
function getTemplateSelect(_value) {
	if (_value != '' && _value != null) {
		var url = "workflow.do?method=preCreateWorkflow&categoryId=" + _value;
		ajaxAnywhere.getAJAX(url);
	}
}

function loadFormatDoc(_t) {
	var _c = $('categoryId').value;
	if (_c != null && _c != '' && _t != '') {
		var url = "workflow.do?method=preCreateWorkflow&categoryId=" + _c
				+ "&templateId=" + _t;
		ajaxAnywhere.getAJAX(url);
	}
}

function saveWorkflowInfo() {
	$(editWorkflowInfoForm).action = "workflow.do?method=createWorkflow";
	ajax_search_list_submit_new('editWorkflowInfoForm', '');
}

function saveWFIAndNext() {
	// 创建第一步骤task
	$(editWorkflowInfoForm).action = "workflow.do?method=createWorkflow&optionType=startWFI";
	ajax_search_list_submit_new('editWorkflowInfoForm', '');
}

function saveWorkflowTask() {
	$(editWorkflowTaskForm).action = $(editWorkflowTaskForm).action;
	$(editWorkflowTaskForm).submit();
}

function saveTaskAndNext() {
	$(editWorkflowTaskForm).action = $(editWorkflowTaskForm).action
			+ "&optionType=nextTask";
	$(editWorkflowTaskForm).submit();
}

function onClickNextStep(_tId, _sId) {
	var url = "workflow.do?method=preCreateNextWorkflowTask&taskId=" + _tId
			+ "&nextStepId=" + _sId;
	ajaxAnywhere.getAJAX(url);
}

// -------------------------------
function viewWorkflowTaskInfo(_tId) {
	var url = "workflow.do?method=viewWorkflowTask&taskId=" + _tId;
	ajaxAnywhere.getAJAX(url);
}

function listWorkflowTaskDoc(_tId) {
	var url = "workflow.do?method=listWorkflowTaskDoc&taskId=" + _tId;
	ajaxAnywhere.getAJAX(url);
}

function listWorkflowTaskRemark(_tId) {
	var url = "workflow.do?method=listWorkflowTaskRemark&taskId=" + _tId;
	ajaxAnywhere.getAJAX(url);
}

function listWorkflowTaskCalendar(_tId) {
	var url = "workflow.do?method=listWorkflowTaskCalendar&taskId=" + _tId;
	ajaxAnywhere.getAJAX(url);
}

function listWorkflowTaskWorkRecord(_tId) {
	var url = "workflow.do?method=listWorkflowTaskWorkRecord&taskId=" + _tId;
	ajaxAnywhere.getAJAX(url);
}

function listRemarkAjax(moduleKey, op, objectId, objectName) {
	ajaxAnywhere.getAJAX("remark.do?method=listByObjectId&moduleKey="
			+ moduleKey + "&op=" + op + "&objectId=" + objectId
			+ "&objectName=" + objectName);
}

//
function listWorkflowDoc(_id) {
	var url = "workflow.do?method=listWorkflowDoc&workflowId=" + _id;
	ajaxAnywhere.getAJAX(url);
}

function gotoNext() {
	$('saveButton').disabled = "disabled";
}

function checkDescription() {
	var frist = document.getElementById('frist');
	if (frist != null) {
		return true;
	} else {
		if ($('description').value == "") {
			alert("签办意见不能为空，请填写");
			return false;
		} else {
			return true;
		}
	}
}

// -----------------------------------------------------

function createSearchCriteria() {
	if (check()) {
		$('SearchWorkflowForm').action = "workflowSearchcriteria.do?method=createSearchCriteria&moduleKey=PM_WORKFLOW&fatherLayer=editSearchCriteria";
		$('SearchWorkflowForm').submit();
	}
}

function editSearchCriteria() {
	if (check()) {
		$('SearchWorkflowForm').action = "workflowSearchcriteria.do?method=editSearchCriteria&moduleKey=PM_WORKFLOW&fatherLayer=editSearchCriteria";
		$('SearchWorkflowForm').submit();
	}
}

function createMineSearchCriteria() {
	if (check()) {
		$('SearchWorkflowForm').action = "workflowSearchcriteria.do?method=createSearchCriteria&moduleKey=PM_MINEWORKFLOW&fatherLayer=createSearchCriteriaMine";
		$('SearchWorkflowForm').submit();
	}
}

function editMineSearchCriteria() {
	if (check()) {
		$('SearchWorkflowForm').action = "workflowSearchcriteria.do?method=editSearchCriteria&moduleKey=PM_MINEWORKFLOW&fatherLayer=createSearchCriteriaMine";
		$('SearchWorkflowForm').submit();
	}
}

// -----------------------------------------

function exportWorkflow(exportWorkflow) {
	var url;
	if (isAdvancedSearch == 'false') {
		url = "workflow.do?method=advancedSearch";
	} else {
		url = "workflow.do?method=exportWorkflow";
	}
	var searchForm = document.getElementById("exportWorkflowForm");
	searchForm.action = url;
	searchForm.submit();
}

function check() {
	if ($('scName').value == "") {
		alert("搜索器名称不能为空.");
		return false;
	} else {
		return true;
	}
}

function _n_searchWorkflow(ownGroups, workflowStauts, workflowType) {
	var searchWorkflowForm = document.getElementById("SearchWorkflowForm");
	searchWorkflowForm.ownGroups.value = ownGroups;
	searchWorkflowForm.workflowStauts.value = projectStatus;
	searchWorkflowForm.workflowType.value = projectType;
	ajax_search_list_submit_new('SearchWorkflowForm', '');
}

function _n_group_searchWorkflow(ownGroups) {
	var searchWorkflowForm = document.getElementById("SearchWorkflowForm");
	searchWorkflowForm.ownGroups.value = ownGroups;
	ajax_search_list_submit_new('SearchWorkflowForm', '');
}

function _n_status_searchWorkflow(workflowStauts) {
	var searchWorkflowForm = document.getElementById("SearchWorkflowForm");
	searchWorkflowForm.workflowStauts.value = SearchWorkflowForm;
	ajax_search_list_submit_new('SearchWorkflowForm', '');
}

function _n_type_searchWorkflow(workflowType) {
	var searchWorkflowForm = document.getElementById("SearchWorkflowForm");
	searchWorkflowForm.workflowType.value = workflowType;
	ajax_search_list_submit_new('SearchWorkflowForm', '');
}
function onceClick(txtObj) {
	var val = document.getElementById(txtObj);
	val.value = "";
}
function exportMineWorkflow() {// (CurrentPage){
	var url = "workflow.do?method=exportMineWorkflow";// &CurrentPage="+CurrentPage;
	$(listWorkflowForm).action = url;
	$(listWorkflowForm).submit();
}
